package ar.edu.unicen.exa.isistan.archassis.rcs.svn;

import java.io.Serializable;

import org.tmatesoft.svn.core.SVNProperties;
import org.tmatesoft.svn.core.wc.SVNRevision;

import ar.edu.unicen.exa.isistan.archassis.rcs.IVersion;

public class SVNVersion implements IVersion, Serializable {
	private long r;
	private SVNProperties properties;
	
	public SVNVersion(long r) {
		this(r, null);
	}
	public SVNVersion(long r, SVNProperties properties) {
		this.r = r;
		this.properties = properties;
	}
	
	private String getPropertiesAsString() {
		if (properties != null) {
			return properties.asMap().toString();
		}
		return "[sin propiedades cargadas]";
	}

	@Override
	public String toString() {
		return "{" + r + " " + getPropertiesAsString() + "}";
	}
	
	//139 de 149: Propiedades {svn:log=TODO's que no servian mas, svn:author=sebastianperruolo@gmail.com, google:author=sebastianperruolo@gmail.com, svn:date=2011-07-21T01:15:40.830507Z}

	public SVNRevision getSVNRevision() {
		return SVNRevision.create(r);
	}
	
	public String getAuthor() {
		return properties.getStringValue("svn:author");
	}
	public String getLog() {
		return properties.getStringValue("svn:log");
	}
	public String getDate() {
		return properties.getStringValue("svn:date");
	}

	@Override
	public String getID() {
		return "rev_" + Long.toString(r);
	}
	
	
}
